package com.dunqi.gpm.cangxi.home.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.dunqi.gpm.cangxi.R;
import com.dunqi.gpm.cangxi.common.base.CommonAdapter;
import com.dunqi.gpm.cangxi.common.base.CommonViewHolder;

import java.util.List;

/**
 * Created by 空 on 2017/11/30 0030.
 */
public class PhotoAdapter extends CommonAdapter<String> {
    public PhotoAdapter(Context context, List<String> list) {
        super(context, list);
    }

    @Override
    public int getLayout(int position) {
        return R.layout.item_image;
    }

    @Override
    public void bindData(CommonViewHolder cvh, int position) {
        String item = getItem(position);
        ImageView view = cvh.getView(R.id.image_iv);
        if (TextUtils.isEmpty(item)) {
            Glide.with(context).load(R.mipmap.add_photo).into(view);
        } else {
            Glide.with(context).load(item).centerCrop().into(view);
        }
    }
}
